﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //var prop = AcmsContext.CurrentPost.FindPostControl("Backgound Image");
            var acmsPage = this.Page as Acms.AcmsControls.TemplatePage;
            if (acmsPage != null && acmsPage.AcmsContext.CurrentPost != null)
            {
                var control = acmsPage.AcmsContext.CurrentPost.FindPostControl("Backgound Image");
                if (control != null)
                {
                    var prop = control.GetProperties<Acms.AcmsControls.ImageContentControlProperties>();
                    if (prop != null && prop.HasResource())
                    {
                        pnlInnerContainer.BackImageUrl = Acms.AcmsControls.RenderFile.GetUrl(prop.ResourceId, this.Page);
                    }
                }
            }
        }
    }
}
